﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAccess.Object;
using System.Data.SqlClient;
using System.Data;

namespace DataAccess
{
    public class LoginDAO
    {
        private DataAccess _conn;
        public LoginDAO()
        {
            _conn = new DataAccess();
            
        }

        public int Login(users us)
        {
            SqlParameter[] param = new SqlParameter[2];

            param[0] = new SqlParameter("@P_TAI_KHOAN", SqlDbType.NVarChar);
            param[0].Value = us.username;

            param[1] = new SqlParameter("@P_MAT_KHAU", SqlDbType.NVarChar);
            param[1].Value = us.password;

            return _conn.ExecuteScalar("LOGIN", param);
        }

        public void DOI_MAT_KHAU(string tai_khoan,string mat_khau_moi)
        {
            SqlParameter[] param = new SqlParameter[2];

            param[0] = new SqlParameter("@P_TAI_KHOAN", SqlDbType.NVarChar);
            param[0].Value = tai_khoan;

            param[1] = new SqlParameter("@P_MAT_KHAU_MOI", SqlDbType.NVarChar);
            param[1].Value = mat_khau_moi;

            _conn.ExecuteNonQuery("UPDATE_MAT_KHAU", param);
        }
    }
}
